package com.msh.artascope.devcloud.service.controller;

import com.msh.frame.client.common.Result;
import com.msh.frame.client.validation.*;
import com.msh.frame.web.base.BaseController;
import com.msh.artascope.devcloud.client.po.GitlabConfigPo;
import com.msh.artascope.devcloud.client.qo.GitlabConfigQo;
import com.msh.artascope.devcloud.service.service.GitlabConfigService;
import javax.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.groups.Default;
import java.util.List;


/**
 * @author shihu
 * @mail m-sh@qq.com
 */
@Tag(name = "gitllab配置-controller相关接口")
@RestController
@RequestMapping("/gitlabConfig")
@Slf4j
public class GitlabConfigController extends BaseController<GitlabConfigPo, GitlabConfigQo> {

  @Autowired
  private GitlabConfigService gitlabConfigService;


  @Operation(summary = "获取详情")
  @GetMapping("get")
  public Result<GitlabConfigPo> get(@NotNull(message = "id不能为空") @RequestParam("id") Long id, @NotNull(message = "tenantId不能为空") @RequestParam("tenantId不能为空") Long tenantId) {
      return Result.successReturn(gitlabConfigService.get(id, tenantId));
  }

  @Operation(summary = "通用查询逻辑")
  @PostMapping("list")
  public Result<List<GitlabConfigPo>> list(@Validated({IList.class,Default.class}) @RequestBody GitlabConfigQo q) {
      return Result.successReturn(gitlabConfigService.list(q));
  }

}
